﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Cheenti
{
    public partial class WebForm4 : System.Web.UI.Page
    {
        const int PageSize = 20;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.TextQuotes1.CurrentPage = 1;
                LoadData(1, PageSize);

                //this.TextSlides1.PageChanged += new EventHandler(TextSlides1_PageChanged);
            }

        }

        private void LoadData(int pageNumber, int pageSize)
        {
            string fileName;



            Cheenti.com.XSD.QuoteTables t = new Cheenti.com.XSD.QuoteTables();
            fileName = System.IO.Path.Combine(Server.MapPath("."), "App_Data\\Quotes.xml");
            t.Quotes.ReadXml(fileName);


            pageNumber--;

            t.Quotes.DefaultView.RowFilter = "Id>" + (pageNumber * pageSize) + " AND Id <=" + (pageNumber * pageSize + pageSize);

            
            this.TextQuotes1.DataSource = t.Quotes.DefaultView;
            this.TextQuotes1.DataBind();
        }

        protected void TextSlides1_PageChanged(object sender, EventArgs e)
        {
            int page = this.TextQuotes1.CurrentPage;
            this.LoadData(page, PageSize);
            this.TextQuotes1.CurrentPage = page;
        }
    }
}